package com.itheima.service.serviceImpl;

import com.itheima.domain.count.ClazzStudentCountVo;
import com.itheima.domain.count.JobCountVo;
import com.itheima.domain.count.StudentCount;
import com.itheima.domain.vo.*;
import com.itheima.mapper.statisticsMapper;
import com.itheima.service.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 上官徵羽
 * @version 1.0
 * @since 2025-08-25 17:00
 */
@Service
public class statisticsServiceImpl implements StatisticsService {
    @Autowired
    private statisticsMapper statisticsMapper;
    @Override
    public JobVo getEmpJobData() {
        List<JobCountVo> jobCountVo = statisticsMapper.getEmpJobData();
        List<String> jobList = jobCountVo.stream().map(JobCountVo::getJobName).toList();
        List<Long> dataList = jobCountVo.stream().map(JobCountVo::getJobCount).toList();
        return new JobVo(jobList,dataList);
    }

    @Override
    public List<EmpGenderVo> getEmpGenderData() {
        List<EmpGenderVo> empGenderVos = statisticsMapper.getEmpGenderData();
        return empGenderVos;
    }

    @Override
    public List<StudentDegreeVo> getStudentDegreeData() {
        List<StudentDegreeVo> studentDegreeVos = statisticsMapper.getStudentDegreeData();
        return studentDegreeVos;
    }

    @Override
    public ClazzStudentCountVo getClazzStudentCountData() {
        List<StudentCount> clazzStudentCountVo = statisticsMapper.getClazzStudentCountData();
        List< String> clazzList = clazzStudentCountVo.stream().map(StudentCount::getClazzName).toList();
        List< Long> dataList = clazzStudentCountVo.stream().map(StudentCount::getStudentNum).toList();
        return new ClazzStudentCountVo(clazzList,dataList);
    }
}
